package com.example.concurrent.PriorityBlockingQueue;

import java.util.Iterator;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * Created by Administrator on 2017/2/10 0010.
 */
public class PriorityBlockingQueueDemo {
    public static void main(String[] args) {


        try {
            BlockingQueue queue   = new PriorityBlockingQueue();
            //String implements java.lang.Comparable
            queue.put("Value2");
            queue.put("Value1");
            queue.put("Value1");
            queue.put("Value2");
            queue.put("Value");

            while (queue.peek()!=null){
                System.out.println(queue.take());
            }

        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
